package cas.ihep.hep.config;

import cas.ihep.hep.config.impl.JSONConfig;

import java.io.InputStream;
import java.util.List;

public interface Config {
    class ConfigException extends RuntimeException{
        public ConfigException(){}
        public ConfigException(String msg){
            super(msg);
        }
        public ConfigException(Throwable ex){
            super(ex);
        }
    }
    String getString(String key)throws ConfigException;
    String getString(String key,String defVal);
    List<String> getStringArray(String key)throws ConfigException;
    int getInt(String key)throws ConfigException;
    int getInt(String key,int defVal);
    List<Integer> getIntArray(String key)throws ConfigException;
    long getLong(String key)throws ConfigException;
    long getLong(String key,long val);
    List<Long> getLongArray(String key)throws ConfigException;
    float getFloat(String key)throws ConfigException;
    float getFloat(String key,float val);
    List<Float> getFloatArray(String key)throws ConfigException;
    double getDouble(String key)throws ConfigException;
    double getDouble(String key,double val);
    List<Double> getDoubleArray(String key)throws ConfigException;
    Config getConfig(String key)throws ConfigException;
    List<Config> getConfigArray(String key)throws ConfigException;

    static Config newJSONConfig(String str){
        return new JSONConfig(str);
    }

    static Config newJSONConfig(InputStream is){
        return new JSONConfig(is);
    }
}
